<template>
  <Drawer title="碎片" v-model="drawShow" :mask-closable="false" @on-close="$emit('on-close')" :width="params[mode].width">
    <p class="title" v-if="important">核心碎片为{{ important }}</p>
    <div class="img-container" :style="{ width: params[mode].imgContainerWidth + 'px' }">
      <div class="img-item" v-for="(item, index) in fragments" :key="index">
        <img :width="params[mode].imgWidth" :src="item.fragmentPic" alt="碎片">
        <div class="tips" style="text-shadow: 2px 2px 4px #888">
          <span>{{item.fragmentNo}}</span>
          <Icon style="margin-left: 5px; position: relative; bottom: 2px" v-if="item.fragmentType" type="ios-star" />
        </div>
      </div>
    </div>
  </Drawer>
</template>

<script>
export default {
  name: 'FragmentCard',
  data () {
    return {
      drawShow: false,
      params: {
        '4': {
          width: 657,
          imgContainerWidth: 605,
          imgWidth: 300
        },
        '6': {
          width: 662,
          imgContainerWidth: 610,
          imgWidth: 200
        },
        '9': {
          width: 662,
          imgContainerWidth: 610,
          imgWidth: 200
        }
      }
    }
  },
  props: {
    show: {
      type: Boolean,
      default: false
    },
    mode: {
      type: Number,
      default: 4 // 碎片数量4, 6, 9
    },
    fragments: {
      type: Array
    },
    important: {
      type: String
    }
  },
  watch: {
    show (val) {
      this.drawShow = val
    }
  }
}
</script>

<style lang="less">
.title {
  text-align: center;
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: 500;
}
.img-container {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  .img-item {
    position: relative;
  }
  .tips {
    display: flex;
    align-items: center;
    position: absolute;
    left: 10px;
    top: 10px;
    color: #fff;
    font-size: 18px;
    font-weight: 500;
  }
}
</style>
